
/**获取地址栏url*/
function getHref(){
	return window.location.href;
}
/**获取请求协议*/
function getProtocol(){
	return window.location.protocol;
}
/**获取主机域名*/
function getHost(){
	return window.location.host;
}
/**获取请求路径*/
function getPathname(){
	return window.location.pathname;
}
/**获取查询参数*/
function getSearch(){
	return window.location.search;
}
/**获取锚点*/
function getHash(){
	return window.location.hash;
}
/**根据键获取查询参数值*/
function getSearchParam(queryStringName){
	var returnValue = '';
	var URLString = new String(document.location);
	var searchLocation = -1;
	var queryStringLength = queryStringName.length;
	do{
		searchLocation = URLString.indexOf(queryStringName + '\=');
		if(searchLocation != -1){
			if((URLString.charAt(searchLocation-1) == '?')||
					(URLString.charAt(searchLocation-1) == '&')){
				URLString = URLString.substr(searchLocation);
				break;
			}
			URLString = URLString.substr(searchLocation + queryStringLength + 1);
		}
	} while(searchLocation != -1)
		
	if(searchLocation != -1){
		var seperatorLocation = URLString.indexOf('&');
		if(seperatorLocation == -1){
			returnValue = URLString.substr(queryStringLength + 1);
		} else {
			returnValue = URLString.substring(queryStringLength + 1,seperatorLocation);
		}
	}
	return returnValue;
	

}

/**
 * 从url中提取全部请求参数
 * @param url
 */
function getRequestParams(url){
	if(!url && url == ''){//如果Url无效或者为空，则返回空串
		return '';
	}
	
	if(url.indexOf('?') != -1){
		var arr1 = url.split('?');
		if(arr1.length > 1){
			return arr1[1];
		}
	}
}

/**
 * 从请求参数中提取键名=paramName的值
 * @param requestParams
 * @param paramName
 */
function getRequestParam(requestParams,paramName){
	if(!requestParams || requestParams == ''){
		return '';
	}
	if(!paramName || paramName == ''){
		return '';
	}
	var arr1 = requestParams.split('&');
	for(var i = 0; i < arr1.length; i++){
		var arr2 = arr1[i].split('=');
		if(arr2.length > 1){
			if(arr2[0] == paramName){
				return arr2[1];
			}
		}
	}
	return '';
}

function   autoImg(){
	$("img").each(function(){
		var maxWidth = 300; // 图片最大宽度
	     var maxHeight = 120;    // 图片最大高度
	     var ratio = 0;  // 缩放比例
	     var width = $(this).width();    // 图片实际宽度
	     var height = $(this).height();  // 图片实际高度
	     // 检查图片是否超宽
	     if(width > maxWidth){
	         ratio = maxWidth / width;   // 计算缩放比例
	         $(this).css("width", maxWidth); // 设定实际显示宽度
	         height = height * ratio;    // 计算等比例缩放后的高度 
	         $(this).css("height", height);  // 设定等比例缩放后的高度
	     }

	     // 检查图片是否超高
	     if(height > maxHeight){
	         ratio = maxHeight / height; // 计算缩放比例
	         $(this).css("height", maxHeight);   // 设定实际显示高度
	         width = width * ratio;    // 计算等比例缩放后的高度
	         $(this).css("width", width * ratio);    // 设定等比例缩放后的高度

	     }
	});
	
}




Date.prototype.format = function(format) {
	var o = {
		"M+" : this.getMonth() + 1,
		"d+" : this.getDate(),
		"h+" : this.getHours(),
		"m+" : this.getMinutes(),
		"s+" : this.getSeconds(),
		"q+" : Math.floor((this.getMonth() + 3) / 3),
		"S" : this.getMilliseconds()
	}
	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	}
	for ( var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
					: ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;

}

/**
 * 获取当前日期的下一天，curDay格式是'yyyy-MM-dd',返回日期格式是'yyyy-MM-dd'
 */
function getNextday(curDay){
	var today= curDay;
	var  t =   new   Date(Date.parse(today.replace(/-/g,   "/")));

	var tm=new Date(t.getFullYear(),t.getMonth(),t.getDate()+1);

	var m='0'+(tm.getMonth()+1);
	var d='0'+tm.getDate()
	var nextDay = tm.getFullYear()+'-'+m.substr(m.length-2)+'-'+d.substr(d.length-2);
	return nextDay;
//	alert(nextDay);
//	document.getElementById("lang0").value= tm.getFullYear()+'-'+m.substr(m.length-2)+'-'+d.substr(d.length-2);

	};

